package cn.org.custom.client.constants;

import cn.org.custom.client.responseHandler.*;
import cn.org.custom.protocol.MessageCodecSharable;
import cn.org.custom.client.handler.HeartBeatHandler;
import cn.org.custom.server.requestHandler.GroupCreateRequestMessageHandler;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.handler.logging.LogLevel;
import io.netty.handler.logging.LoggingHandler;
import io.netty.handler.timeout.IdleStateHandler;

import java.util.Scanner;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicBoolean;


public class Constants {

    /**
     * 线程安全类【程序状态】
     */
    public static final AtomicBoolean LOGIN = new AtomicBoolean(false);
    public static final AtomicBoolean EXIT = new AtomicBoolean(false);
    /**
     * 同步辅助类，它允许一个或多个线程等待一组操作在其他线程中完成
     */
    public static final CountDownLatch WAIT_FOR_LOGIN = new CountDownLatch(1);
    /**
     * boos
     */
    public static final NioEventLoopGroup group = new NioEventLoopGroup();
    /**
     * 日志
     */
    public static final LoggingHandler LOGGING_HANDLER = new LoggingHandler(LogLevel.DEBUG);
    /**
     * 编解码器
     */
    public static final MessageCodecSharable MESSAGE_CODEC = new MessageCodecSharable();
    /**
     * 写事件超时监听器
     */
    public static final IdleStateHandler IDLE_STATE_HANDLER = new IdleStateHandler(0, 3, 0);
    /**
     * 心跳
     */
    public static final HeartBeatHandler HEART_BEAT_HANDLER = new HeartBeatHandler();
    public static final Scanner scanner = new Scanner(System.in);

    /**
     * 业务处理器
     */
    public static final PongMessageHandler PONG_MESSAGE_HANDLER = new PongMessageHandler();
    public static final ChatResponseMessageHandler CHAT_RESPONSE_MESSAGE_HANDLER = new ChatResponseMessageHandler();
    public static final GroupChatResponseHandler GROUP_CHAT_RESPONSE_HANDLER = new GroupChatResponseHandler();
    public static final GroupCreateResponseHandler GROUP_CREATE_RESPONSE_HANDLER = new GroupCreateResponseHandler();
    public static final GroupJoinResponseHandler GROUP_JOIN_RESPONSE_HANDLER = new GroupJoinResponseHandler();
    public static final GroupMembersResponseHandler GROUP_MEMBERS_RESPONSE_HANDLER = new GroupMembersResponseHandler();
    public static final GroupQuitResponseMessageHandler GROUP_QUIT_RESPONSE_MESSAGE_HANDLER = new GroupQuitResponseMessageHandler();
    public static final LoginResponseMessageHandler LOGIN_RESPONSE_MESSAGE_HANDLER = new LoginResponseMessageHandler();
}
